package cn.clx.ymcc.web.controller;

import cn.clx.ymcc.dto.RegisterDto;
import cn.clx.ymcc.result.JSONResult;
import cn.clx.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;


    @GetMapping("/imgCode/{key}")
    public JSONResult verifyCode(@PathVariable("key") @NotEmpty(message = "UUID不能为空啊") String key){

        String base64 = verifyCodeService.verificationCode(key);
        return JSONResult.success(base64);
    }
    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody @Valid RegisterDto dto) {

        verifyCodeService.sendSmsCode(dto);
        return JSONResult.success();
    }
}
